Add more columns to the settings demo
authorMatthias Clasen <mclasen@redhat.com>
Mon, 1 Jun 2020 18:46:12 +0000 (14:46 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 2 Jun 2020 02:10:53 +0000 (22:10 -0400)
Flesh out this demo more, so we can have a
non-trivial column editor here at some point.

demos/gtk-demo/listview_settings.c
demos/gtk-demo/listview_settings.ui

index 24c42ea232781de605d28da7e548ce735c2d3e26..5bb7a2b8cc83ba64e8b2019456461b3113f2e3ca 100644 (file)
@@ -302,6 +302,8 @@ do_listview_settings (GtkWidget *do_widget)
       GtkColumnViewColumn *name_column;
       GtkColumnViewColumn *type_column;
       GtkColumnViewColumn *default_column;
+      GtkColumnViewColumn *summary_column;
+      GtkColumnViewColumn *description_column;
       GtkSorter *sorter;
       GActionGroup *actions;
       GAction *action;
@@ -326,6 +328,8 @@ do_listview_settings (GtkWidget *do_widget)
       columnview = GTK_WIDGET (gtk_builder_get_object (builder, "columnview"));
       type_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "type_column"));
       default_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "default_column"));
+      summary_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "summary_column"));
+      description_column = GTK_COLUMN_VIEW_COLUMN (gtk_builder_get_object (builder, "description_column"));
 
       actions = G_ACTION_GROUP (g_simple_action_group_new ());
 
@@ -337,6 +341,14 @@ do_listview_settings (GtkWidget *do_widget)
       g_action_map_add_action (G_ACTION_MAP (actions), action);
       g_object_unref (action);
 
+      action = G_ACTION (g_property_action_new ("show-summary", summary_column, "visible"));
+      g_action_map_add_action (G_ACTION_MAP (actions), action);
+      g_object_unref (action);
+
+      action = G_ACTION (g_property_action_new ("show-description", description_column, "visible"));
+      g_action_map_add_action (G_ACTION_MAP (actions), action);
+      g_object_unref (action);
+
       gtk_widget_insert_action_group (columnview, "columnview", actions);
       g_object_unref (actions);
 
index 96d2a22cfe6e23f24f674ce7d499d4dc24940cee..d5678031407ec5cb623e13cbbde9d9f2ca282ee9 100644 (file)
       </object>
     </property>
   </template>
+</interface>
+                        ]]></property>
+                          </object>
+                        </property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkColumnViewColumn" id="summary_column">
+                        <property name="title">Summary</property>
+                        <property name="visible">0</property>
+                        <property name="header-menu">header_menu</property>
+                        <property name="factory">
+                          <object class="GtkBuilderListItemFactory">
+                            <property name="bytes"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GtkListItem">
+    <property name="child">
+      <object class="GtkLabel">
+        <property name="xalign">0</property>
+        <property name="wrap">1</property>
+        <property name="width-chars">50</property>
+        <property name="max-width-chars">50</property>
+        <binding name="label">
+          <lookup name="summary" type="SettingsKey">
+            <lookup name="item">GtkListItem</lookup>
+          </lookup>
+        </binding>
+      </object>
+    </property>
+  </template>
+</interface>
+                        ]]></property>
+                          </object>
+                        </property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkColumnViewColumn" id="description_column">
+                        <property name="title">Description</property>
+                        <property name="visible">0</property>
+                        <property name="header-menu">header_menu</property>
+                        <property name="factory">
+                          <object class="GtkBuilderListItemFactory">
+                            <property name="bytes"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GtkListItem">
+    <property name="child">
+      <object class="GtkLabel">
+        <property name="xalign">0</property>
+        <property name="wrap">1</property>
+        <property name="width-chars">50</property>
+        <property name="max-width-chars">50</property>
+        <binding name="label">
+          <lookup name="description" type="SettingsKey">
+            <lookup name="item">GtkListItem</lookup>
+          </lookup>
+        </binding>
+      </object>
+    </property>
+  </template>
 </interface>
                         ]]></property>
                           </object>
         <attribute name="label" translatable="yes">Default value</attribute>
         <attribute name="action">columnview.show-default</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">Summary</attribute>
+        <attribute name="action">columnview.show-summary</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Description</attribute>
+        <attribute name="action">columnview.show-description</attribute>
+      </item>
     </section>
   </menu>
 </interface>